package com.inspur.attendance.Dao;

import com.inspur.attendance.Entity.Daily;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Repository
public interface DailyDao extends JpaRepository<Daily, Long> {

    @Transactional
    @Query(value = "select * from daily where date(create_time) between ?1 and ?2", nativeQuery = true)
    Page<Daily> findByDate(Date startDate, Date endDate, Pageable pageable) throws Exception;

    List<Daily> findByApplicant(String application) throws Exception;

    Daily findTopById(Long id)throws Exception;

    Daily findTopByApplicant(String  id)throws Exception;
}
